package com.service.imple.home;

import com.dao.GoodsMapper;
import com.entity.Goods;
import com.entity.Size;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.home.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GoodsImple implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public PageInfo<Goods> selectByPage(Map<String, Object> param) {
        int pageNum=Integer.parseInt(param.get("pageNum").toString());
        PageHelper.startPage(pageNum,6);
        List<Goods> list = goodsMapper.selectPage(param);
        PageInfo<Goods> info =new PageInfo<>(list);
        return info;
    }

    @Override
    public List<Goods> select(Map map) {
        return null;
    }

    @Override
    public int insert(Goods goods) {
        return goodsMapper.insert(goods);
    }

    @Override
    public int update(Goods goods) {
        return goodsMapper.updateByPrimaryKey(goods);
    }

    @Override
    public int delete(int id) {
        return goodsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Goods> selectAll(Goods goods) {
        return goodsMapper.selectAll(goods);
    }

    @Override
    public List<Goods> selectPage(Map map) {
        return null;
    }

    @Override
    public List<Goods> selectPrice(Size size) {
        return goodsMapper.selectPrice(size);
    }

    @Override
    public List<Goods> selectDate(Goods goods) {
        return goodsMapper.selectDate(goods);
    }

    @Override
    public List<Goods> selectClick(Goods goods) {
        return goodsMapper.selectClick(goods);
    }

    @Override
    public List<Goods> selectPriceDesc(Goods goods) {
        return goodsMapper.selectPriceDesc(goods);
    }

    @Override
    public List<Goods> selectPriceAsc(Goods goods) {
        return goodsMapper.selectPriceAsc(goods);
    }

    @Override
    public List<Goods> selectLike(Goods goods) {
        return goodsMapper.selectLike(goods);
    }
}
